using dx.User.Api;
using dx.User.Api.Controllers;
using Dx.DDD.Repositories;
using Dx.Test.MySqlEntityFrameworkCore;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

//builder.Services.AddControllers();
builder.Services.AddControllers();
    //.AddModuleConctroller();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
//builder.
//    Services.AddDbContextPool<MyDbContext>(opt => {
//        opt.UseMySql("Data Source=localhost;Database=sys_portal;AllowLoadLocalInfile=true;User ID=root;Password=root;allowPublicKeyRetrieval=true;pooling=true;CharSet=utf8;port=3306;sslmode=none;", new MySqlServerVersion(new Version(5, 7, 36)));

//    });
builder.Services.Configured(builder.Configuration);
//builder.Services.AddScoped<UserManagerController>();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();
//var scope= app.Services.CreateScope();
//var service = scope.ServiceProvider;
//var ssfsf= service.GetServices(typeof(MyDbContext));
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseUnitOfWork();
app.UseAuthorization();

app.MapControllers();

app.Run();
